package main

import (
	"flag"
	"fmt"
	"logbeat/internal/beat"
	"logbeat/internal/config"
	"logbeat/internal/ectx"
	"os"
	"os/signal"
	"syscall"

	"logbeat/internal/genlog"

	"gitee.com/lambdang/pkg/logx"
	"gitee.com/lambdang/pkg/yamlconfig"
)

var configFile = flag.String("f", "./config.yaml", "the config file")

func main() {
	cfg:=&config.Config{}

	yamlconfig.MustLoad(*configFile,cfg)
	fmt.Println(cfg)

	log,err:=logx.NewLogx(cfg.Log)
	log.Debug("logbeat start...")
	if err!=nil{
		panic(err)
	}
	ectx := &ectx.Ectx{
		Config: cfg,
		Log: log,
	}


	go genlog.Genlog("./test.log")
	
	beat.NewBeat(ectx).Tail()
	quit := make(chan os.Signal)
	signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
	<-quit

}